package com.oliver.picturebackendcommon.model.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

/**
 * @ClassName PictureFetchSourceEnum
 * @Description TODO
 * @Author snow
 * @Date 2024/12/15 15:53
 **/

@Getter
public enum PictureFetchSourceEnum {
    DEFAULT("biyin","","必应图片"),
    BAIDU("baidu","","百度图片")
    ;

    private String code;

    private String url;

    private String desc;

    PictureFetchSourceEnum(String code, String url, String desc) {
        this.code = code;
        this.url = url;
        this.desc = desc;
    }

    public static String getUrlByCode(String code){
        if (StrUtil.isBlank(code)){
            return DEFAULT.url;
        }
        for (PictureFetchSourceEnum sourceEnum : PictureFetchSourceEnum.values()) {
            if (sourceEnum.code.equals(code)){
                return sourceEnum.url;
            }
        }
        return DEFAULT.url;
    }
}
